<template>
  <el-container class="home-container">
    <el-header>
      <div>
        <!-- <img src="../assets/heima.png" alt="" /> -->
                <span>欢迎登录瑞和大学图书管理系统</span>
                <span style="color: #ccc; font-size: 16px">借阅者管理界面</span>
      </div>
            <div>
              <div>
                <el-avatar :src="photo" :size="35"
                           style="margin-right: 10px"></el-avatar>
              </div>

              <div class="user">用户: {{ username }}</div>
              <el-button type="info" @click="logout">退出</el-button>
            </div>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏菜单区域 -->
      <el-menu  :default-active="activePath"
                class="el-menu-vertical-demo"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b" :router="true" :collapse="isCollapse" :collapse-transition="false">
        <el-menu-item index="index" @click="saveNavState('index')">
          <i class="iconfont icon-shouye"></i>
          <span slo="title">首页</span>
        </el-menu-item>
        <el-menu-item index="bookSearch" @click="saveNavState('bookSearch')">
          <i class="iconfont icon-tubiaozhizuomoban-37"></i>
          <span slot="title">图书管理</span>
        </el-menu-item>
        <el-menu-item index="userSearch" @click="saveNavState('userSearch')">
          <i class="iconfont icon-yuangongguanli"></i>
          <span slot="title">员工管理</span>
        </el-menu-item>
        <el-menu-item index="supplierSearch" @click="saveNavState('supplierSearch')">
          <i class="iconfont icon-gongyingshangguanli"></i>
          <span slot="title">供应商管理</span>
        </el-menu-item>
        <el-menu-item index="departmentSearch" @click="saveNavState('departmentSearch')">
          <i class="iconfont icon-gongyingshangguanli"></i>
          <span slot="title">部门管理</span>
        </el-menu-item>
        <el-menu-item index="borrowSearch" @click="saveNavState('borrowSearch')">
          <i class="iconfont icon-jieyueguanli"></i>
          <span slot="title">借阅管理</span>
        </el-menu-item>
        <el-menu-item index="orderSearch" @click="saveNavState('orderSearch')">
          <i class="iconfont icon-caigouguanli"></i>
          <span slot="title">图书采购管理</span>
        </el-menu-item>
        <el-menu-item index="systemManager" @click="saveNavState('systemManager')">
          <i class="iconfont icon-xitongguanli"></i>
          <span slot="title">系统管理</span>
        </el-menu-item>
      </el-menu>
      <el-main>
        <router-view></router-view>
        <div class="footer">
          <p>
            Copyright ©2023 瑞和大学图书馆 All rights reserved.
          </p>
        </div>
      </el-main>
    </el-container>

  </el-container>
</template>
<script>
import photo from "@/assets/images/user-default.png";
export default {
  data(){
    return {
      //被激活的链接地址
      activePath: "",
      photo:photo,
      isCollapse: false,
      user: {
        userId: Number,
        cardNumber: Number,
        ruleNumber: Number,
        status: Number,
        cardName: "",
        username: "",
        password: "",
        createTime: "",
        updateTime: "",
      }
    }
  },
  methods: {
    logout() {
      window.sessionStorage.clear();
      localStorage.removeItem('username');
      this.$router.push("/login");
    },
    //保存链接的激活状态
    saveNavState(activePath) {
      // console.log("first")
      window.sessionStorage.setItem("activePath", activePath);
      this.activePath = activePath;
      // console.log(this.activePath);
    },
  },created() {
    this.username = localStorage.getItem('username');
  }
}
</script>
<style lang="less" scoped>
.home-container{
  height: 100%;
}
.el-header {
  background-color: rgb(34, 34, 34);
  display: flex;
  justify-content: space-between;
  padding-left: 0px;
  align-items: center;
  color: #fff;
  font-size: 20px;
  border-radius: 10px;

  >div {
    display: flex;
    align-items: center;

    span {
      margin-left: 15px;
    }
  }
}

.el-aside {
  background-color: #fff;

  .el-menu {
    border-right: none;
  }
}

.el-main {
  background-color: #eaedf1;
  padding: 20px;
}

.iconfont {
  margin-right: 10px;
}

.toggle-button {
  background-color: #4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  //设置文字之间的间距
  letter-spacing: 0.2em;
  cursor: pointer;
}

.user {
  margin-right: 15px;
  color: #ccc;
  font-size: 16px;
}

.el-menu-item:hover {
  background-color: rgb(51, 122, 183) !important;
}
.el-menu{
  height: 150vh;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

.footer {
  position: fixed;
  bottom: 0px;
  left: 50%;
  color: #ccc;

  a {
    color: #ccc;
  }
}
</style>